using System.Data.Entity.ModelConfiguration;
using Nop.Core.Domain.Orders;

namespace Nop.Data.Mapping.Orders
{
    public partial class InvoiceMap : EntityTypeConfiguration<Invoice>
    {
        public InvoiceMap()
        {
            this.ToTable("Invoice");
            this.HasKey(i => i.Id);

            this.Property(i => i.Tax).HasPrecision(18, 4);
            this.Property(i => i.Discount).HasPrecision(18, 4);
            this.Property(i => i.SubTotal).HasPrecision(18, 4);
            this.Property(i => i.Total).HasPrecision(18, 4);
            this.Property(i => i.MonthlyCharge).HasPrecision(18, 4);
            this.Property(i => i.StorageCharge).HasPrecision(18, 4);
            this.Property(i => i.TransactionProcessingCharge).HasPrecision(18, 4);
            this.Property(i => i.ServiceCharge).HasPrecision(18, 4);
            this.Property(i => i.FuelSurcharge).HasPrecision(18, 4);

            this.Property(i => i.Name).HasMaxLength(255);

            this.Ignore(i => i.InvoiceStatus);

            this.HasMany(i => i.Orders)
                .WithOptional(i => i.Invoice)
                .HasForeignKey(i => i.InvoiceId)
                .WillCascadeOnDelete(false);
        }
    }
}